package com.job.ZhangMeng.Homework0709;

/**
 * 2022.07.09  杨辉三角--二维数组练习
 * 张孟
 */

public class Homework0709_B {
    public static void main(String[] args) {
        int[][] arr=new int[6][6];
        int count=0;
        for(int i=0;i<6;i++)
        {
            for(int j=0;j<=i;j++)
            {
                if(j==0 || j==i)    //每行两侧为1
                    arr[i][j]=1;
                else                //每行中间为上一行两侧之和
                    arr[i][j]=arr[i-1][j-1]+arr[i-1][j];
            }
        }
        for(int a=0;a<6;a++)
            for(int b=0;b<6;b++)
            {
                if(arr[a][b]!=0)
                    System.out.print(arr[a][b]+"\t");
                count+=1;
                if(count==6)
                {
                    System.out.println("\n");
                    count=0;
                }
            }
    }
}
